﻿set(TARGET_NAME BluetoothCpp)

include_directories(${PROJECT_SOURCE_DIR}/lib/include)

add_compile_definitions(BLUETOOTH_CPP_LIB)

file(GLOB HEADERS "*.h")
file(GLOB PRIVATES "Private/*.h" "Private/*.cpp")
file(GLOB SOURCES "*.cpp")
file(GLOB DOCS "Docs/*.qdoc")
source_group("Headers" FILES ${HEADERS})
source_group("Sources" FILES ${SOURCES})
source_group("Privates" FILES ${PRIVATES})
source_group("Docs" FILES ${DOCS})

if(BLUETOOTH_CPP_STATIC)
 add_compile_definitions(BLUETOOTH_CPP_STATIC)
 set(BLUETOOTH_OPT)
else(BLUETOOTH_CPP_STATIC)
 set(BLUETOOTH_OPT SHARED)
endif(BLUETOOTH_CPP_STATIC)

add_library(${TARGET_NAME} ${BLUETOOTH_OPT}
    ${HEADERS}
    ${SOURCES}
    ${PRIVATES}
    ${DOCS}
    )

if(BLUETOOTH_CPP_STATIC)
else()
 target_link_libraries(${TARGET_NAME} PUBLIC ws2_32 Bthprops)
endif(BLUETOOTH_CPP_STATIC)

set_target_properties(${TARGET_NAME} PROPERTIES PUBLIC_HEADER "${HEADERS}")
set_property(TARGET ${TARGET_NAME} PROPERTY FOLDER "Drivers")

install(TARGETS ${TARGET_NAME}
    CONFIGURATIONS Debug
    RUNTIME DESTINATION ${INSTALL_BINDIR}/Debug
    ARCHIVE DESTINATION ${INSTALL_LIBRARYDIR}
    PUBLIC_HEADER DESTINATION ${INSTALL_INCLUDEDIR}/${TARGET_NAME}
)
install(TARGETS ${TARGET_NAME}
    CONFIGURATIONS Release
    RUNTIME DESTINATION ${INSTALL_BINDIR}/Release
    ARCHIVE DESTINATION ${INSTALL_LIBRARYDIR}
    PUBLIC_HEADER DESTINATION ${INSTALL_INCLUDEDIR}/${TARGET_NAME}
)
